answer "Do you want to Quit or go Home?" with "Quit" or "Home" or "Cancel"
if it is "Cancel" then exit mouseUp
if it is "Quit" then
DoMenu "Quit Hypercard"
else go home
end mouseUp
-- part 23 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=99 top=8 right=39 bottom=206
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 132
-- text size: 24
-- style flags: 0
-- line height: 32
-- part name: subject 2
-- part 24 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=248 top=5 right=22 bottom=512
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 136
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Instructions
-- part 26 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=333 top=307 right=332 bottom=495
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 132
-- text size: 18
-- style flags: 0
-- line height: 24
-- part name: Update this Stack
----- HyperTalk script -----
on mouseUp
import
end mouseUp
-- List of handlers:
-- on import
-- on deleteOldCards
-- on clearFields
-- on importText fileName,checkForDupes
-- on doMiniFinderSort
-- function miniFinderOrder()
-- handler for importing new data into MiniFinders Stack:
on import
GLOBAL howManyRecords
put the userlevel into priorUserlevel
set the userlevel to 5
answer "Import new Data?" with "OK" or "Cancel"
if it is "Cancel" then exit import
answer "Append data or replace?" with "Append" or "Replace" or "Cancel"
if it is "Cancel" then exit import
startProgress
if it is "Replace" then
if permission ("trash all old data") is "Cancel" then
progressOver
exit import
end if
put "Now deleting all your old cards..." into cd fld WhatamIDoing
show cd fld WhatamIDoing
lock screen
deleteOldCards
end if
go card updateCard
unlock screen
put fileName()into fileName
if fileName is empty then
answer "Import Canceled!"
hide cd fld WhatamIDoing
progressOver
exit import
end if
if the visible of cd fld WhatamIDoing is false then show cd fld WhatamIDoing
put "Now importing text data..." into cd fld WhatamIDoing
refresh
lock screen
importText fileName,it -- it now contains "Append" or "Replace"
go card updateCard
unlock screen
put "Now Sorting cards..." into cd fld WhatamIDoing
lock screen
doMiniFinderSort
go card updateCard
unlock screen
put "Now Compacting Stack." into cd fld WhatamIDoing
doMenu "Compact Stack"
lock screen
progressOver
hide cd fld WhatamIDoing
unlock screen
answer ("Done. Imported" && howManyRecords && "entries") with "Finally"
set userlevel to priorUserlevel
end import
-- deletes all old cards
on deleteOldCards
put the number of cards in bg data into total
put true into alltheWay
put progressRect() into pRect
go card 1 of bg data
clearFields
put true into alltheWay
go next card
repeat with i = 2 to total
doMenu "Delete Card"
go cd 2 of bg data
colorRectProgress pRect,i,total,blue
if the mouseClick then
if abortSearch() is true then
put false into alltheWay
go card updateCard
progressOver
hide card fld WhatAmIDoing
exit to HyperCard
end if
end if
end repeat
if alltheWay is true then
colorRectProgress pRect,total,total,blue
end if
end deleteOldCards
-- clears out data in all flds on a card
on clearFields
repeat with i = 1 to the number of flds
put empty into fld i
end repeat
end clearFields
-- Where text gets imported. Also checks for duplicate products, so
-- their review text or ratings may be changed.
on importText fileName,checkForDupes
GLOBAL howManyRecords
put true into alltheWay
put 600 into total -- expecting around 600 to import
put progressRect() into pRect
go to last card of bg data
open file fileName
put 1 into counter
-- here is the core of the whole import process:
repeat
set cursor to busy
add 1 to counter
colorRectProgress pRect,counter,total,blue
read from file fileName until tab
if it is empty then exit repeat
delete last char of it
put it into SubjectHolder
read from file fileName until tab
delete last char of it
if checkForDupes is "Append" then
do ("find whole" && quote & it & quote && "in fld Product")
if the result is "not found" then
go last cd of bg data
doMenu "New Card"
end if
end if
put SubjectHolder into fld "Subject"
put it into fld "Product"
read from file fileName until tab
delete last char of it
put word 1 of it into fld "numericMice"
put mouseEquivalent(word 1 of it) into fld "Mice"
read from file fileName until tab
delete last char of it
put it into fld "Descript"
read from file fileName until tab
delete last char of it
put it into fld "Company Name"
read from file fileName until tab
delete last char of it
put it into fld "St Address"
read from file fileName until tab
delete last char of it
put it into fld "City"
read from file fileName until tab
delete last char of it
put it into fld "Phone"
read from file fileName until tab
delete last char of it
put it into fld "Date Reviewed"
read from file fileName until tab
delete last char of it
put it into fld "Version Shipping"
read from file fileName until tab
delete last char of it
put it into fld "Price"
read from file fileName until return
delete last char of it
put it into fld "Eddy"
if the mouseClick then -- check for mouse click to abort ...
if abortSearch() is true then
put false into alltheWay
go cd findCard
exit repeat
end if
end if
if checkForDupes is "Replace" then doMenu "New Card"
end repeat
if alltheWay is true then
colorRectProgress pRect,total,total,blue
end if
close file fileName
-- clear out any empty cards at the end of the stack...
go to last card of bg data
repeat
if fld subject = "" then doMenu "Delete Card"
go last card of bg data
if fld subject ≠ empty then exit repeat
end repeat
put counter into howManyRecords
end importText
on doMiniFinderSort
sort by miniFinderOrder()
end doMiniFinderSort
-- This function orders the cards so that all 'shell' cards
-- (Table of Contents, Find, Help, etc.) are not reordered, but
-- the new cards created or appended are sorted alphabetically by
-- subject and alphabetically by product within each subject.
function miniFinderOrder
if short name of this bg = "Shell" then
return "AAAAAAAA"
end if
if fld "Subject" = "" then return "ZZZZZZZZ"
return fld "Subject" && fld "Product"
end miniFinderOrder
-- part 27 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=181 top=307 right=332 bottom=326
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 132
-- text size: 18
-- style flags: 0
-- line height: 24
-- part name: About Zmac
----- HyperTalk script -----
on mouseUp
visual effect dissolve
go to card id 49233
end mouseUp
-- part contents for card part 1
----- text -----
Read this first to update the MiniFinders:
1) Download the stuffed text file from Zmac, and ‘unstuff’ it using the utilities StuffIt or UnStuffIt. which are also available for download on Zmac. For more information on Zmac, read the About MacUser section available from the Title card of this stack.
2) For convenience, place the unstuffed file in the same folder as this stack.
3) Open this stack. Go to this card. Click on the button below called
‘Update this Stack...’. You now must choose between replacing all your current information, or appending and updating your listings. A text file from Zmac named ‘Complete MiniFinders’ will allow you to Replace your current information. A text file from Zmac called ‘MiniFinder Update’ will require you to Append new information. If you have any doubt about which to do, click on Cancel, or try ‘Update’ first with a copy of this stack.
4) You will see a dialog for the file to import. Choose your text file. The stack will do the rest.